﻿//==============================================================================  
//Copyright (C) 2012-2015 9UN.ORG. All rights reserved. 
//GUID：46172595-6b69-4526-b9da-426d663f5b05
//CLR Version: 4.0.30319.18033
//Code Author：Kevin Wang
//Contact：Email(Admin@9un.org),QQ(265382 or 74344)
//Filename：MediaInfoInterop
//Namespace：RuanRang.Media.Core.MediaInfo
//Functions：MediaInfoInterop  
//Created by Kevin Wang at 2013/2/2 23:05:09 http://blog.9un.org
//============================================================================== 

using System;
using System.Runtime.InteropServices;
using System.Security;

namespace RuanRang.Media.MediaInfo
{
    /// <summary>
    /// Import of DLL functions. DO NOT USE until you know what you do (MediaInfo DLL do NOT use CoTaskMemAlloc to allocate memory)
    /// </summary>
    internal static class MediaInfoInterop
    {
        /// <summary>
        /// Medias the info_ new.
        /// </summary>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_New();

        /// <summary>
        /// Medias the info_ delete.
        /// </summary>
        /// <param name="handle">The handle.</param>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern void MediaInfo_Delete(IntPtr handle);

        /// <summary>
        /// Medias the info_ open.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_Open(IntPtr handle, [MarshalAs(UnmanagedType.LPWStr)] string fileName);

        /// <summary>
        /// Medias the info_ close.
        /// </summary>
        /// <param name="handle">The handle.</param>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern void MediaInfo_Close(IntPtr handle);

        /// <summary>
        /// Medias the info_ inform.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="reserved">The reserved.</param>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_Inform(IntPtr handle, IntPtr reserved);

        /// <summary>
        /// Medias the info_ get I.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="streamKind">Kind of the stream.</param>
        /// <param name="streamNumber">The stream number.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="kindOfInfo">The kind of info.</param>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_GetI(IntPtr handle, IntPtr streamKind, IntPtr streamNumber, IntPtr parameter, IntPtr kindOfInfo);

        /// <summary>
        /// Medias the info_ get.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="streamKind">Kind of the stream.</param>
        /// <param name="streamNumber">The stream number.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="kindOfInfo">The kind of info.</param>
        /// <param name="kindOfSearch">The kind of search.</param>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_Get(IntPtr handle, IntPtr streamKind, IntPtr streamNumber, [MarshalAs(UnmanagedType.LPWStr)] string parameter, IntPtr kindOfInfo, IntPtr kindOfSearch);

        /// <summary>
        /// Medias the info_ option.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="option">The option.</param>
        /// <param name="value">The value.</param>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_Option(IntPtr handle, [MarshalAs(UnmanagedType.LPWStr)] string option, [MarshalAs(UnmanagedType.LPWStr)] string value);

        /// <summary>
        /// Medias the info_ state_ get.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_State_Get(IntPtr handle);

        /// <summary>
        /// Medias the info_ count_ get.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="streamKind">Kind of the stream.</param>
        /// <param name="streamNumber">The stream number.</param>
        /// <returns>IntPtr.</returns>
        [DllImport("MediaInfo.dll", ExactSpelling = true)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr MediaInfo_Count_Get(IntPtr handle, IntPtr streamKind, IntPtr streamNumber);
    }
}